/*****************************************************************//**
 * \file   ModelConfig.h
 * \brief  读取配置文件模块
 * 
 * \author wangyingjie
 * \date   March 2025
 *********************************************************************/

#ifndef MODEL_CONFIG_H
#define MODEL_CONFIG_H

#include "project_marco.h"


/**
 * @class ModelConfig
 * @brief CAD配置文件读取类
 */
class ModelConfig :public studio_singleton<ModelConfig>
{
public:

	/**
	 * @brief 读取配置文件
	 * @param path 配置文件路径
	 * @return bool 读取状态
	 */
	bool read_config(const std::string& path)
	{
		bool status = false;
            Json::Value root = studio_json::loadf(path);
		if (root.isNull())
		{
			std::cout << "read config file failed!" << std::endl;
			return false;
		}
		if (!studio_json::check_double(root, "width", width))
		{
			std::cout << "missing width in config file!" << std::endl;
			return false;
		}
		if (!studio_json::check_double(root, "height", height))
		{
			std::cout << "missing height in config file!" << std::endl;
			return false;
		}
		if (!studio_json::check_double(root, "theta", theta))
		{
			std::cout << "missing theta in config file!" << std::endl;
			return false;
		}
		if (!studio_json::check_double(root, "distance", distance))
		{
			std::cout << "missing distance in config file!" << std::endl;
			return false;
		}
		status = true;
		return status;
	}

	double width{ 0.0 };	// 底边宽度
	double height{ 0.0 };	// 高度
	double theta{ 0.0 };	// 腰与底边的垂线夹角
	double distance{ 0.0 };  // 拉伸距离
};



#endif //MODEL_CONFIG_H
